package org.xteam.sled.semantic.exp;

public class ExpShift extends Exp {

	private Exp expr;
	private int amount;

	public ExpShift(Exp expr, int amount) {
		this.expr = expr;
		this.amount = amount;
	}
	
	public Exp getExpr() {
		return expr;
	}
	
	public int amount() {
		return amount;
	}
	
	@Override
	public int hashCode() {
		return expr.hashCode() + amount;
	}
	
	@Override
	public boolean equals(Object o) {
		return (o instanceof ExpShift)
			&& ((ExpShift)o).amount == amount
			&& ((ExpShift)o).expr.equals(expr);
	}

	@Override
	public void visit(IExpVisitor visitor) {
		visitor.visitShift(this);
	}
	
	public String toString() {
		return "shift(" + expr + "," + amount +")";
	}

}
